<?php
/**
 * Character model test file.
 *
 * Infectamic: browser game (http://infectamic.goldzoneweb.info)
 * Copyright 2011, Loic Chardonnet
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 */

App::import('Model', 'Character');

/**
 * Class for Character model test.
 */
class CharacterTestCase extends CakeTestCase {
    var $fixtures = array('app.character', 'app.letter', 'app.letter_link');

    function startTest() {
        $this->Character =& ClassRegistry::init('Character');
    }

    function endTest() {
        unset($this->Character);
        ClassRegistry::flush();
    }

    function testRandomGeneration() {
        $nbCharactersBefore = $this->Character->find('count');

        $this->Character->generateRandomly();

        $nbCharactersAfter = $this->Character->find('count');

        $this->assertEqual($nbCharactersAfter, $nbCharactersBefore + 1);
    }

    function testCountGeneratedForLastDay() {
        $nbGeneratedForLastDay = $this->Character->countGeneratedForLastDay();

        $expectedNbGeneratedForLastDay = 0;

        $this->assertEqual($nbGeneratedForLastDay, $expectedNbGeneratedForLastDay);
    }

    function testRemoveDeads() {
        $this->Character->removeDeads();

        $nbCharacters = $this->Character->find('count');

        $expectedNbCharacters = 0;

        $this->assertEqual($nbCharacters, $expectedNbCharacters);
    }
}
